<?php
$loader->requireOnce('includes/inPatientCore/InPatientCoreErrorCode.class.php');
$loader->requireOnce('includes/inPatientCore/InPatientCoreException.class.php');
$loader->requireOnce('includes/CoreErrorCode.class.php');
$loader->requireOnce('includes/CoreException.class.php');
$loader->requireOnce('includes/inPatientCore/TreatingPatientProcessor.class.php');



/**
 * C_TicketTest.
 * @package core.controllers
 * @author viethd
 * @version $Id$
 * @copyright 2009 LHV Company
 */
class C_TicketTest extends Controller  {
	private $logger ;
	

	/**
	 *
	 * @param $controller controller for build ui
	 */
	function __construct($template_mod = "general") {
		parent::__construct($template_mod);
		$this->logger = LoggerManager::getLogger('core.controllers.C_TicketTest');
		$this->template_mod = $template_mod;
		$this->view->path="ticket_test";		
	}



	function actionViewPatientTestAjax() {
		$result = array('error'=>array('code'=>0,'mess'=>''), 'result'=>'');
		$this->logger->info('Start actionViewPatientTestAjax');
		$patienId = $_GET['patientId'];
		try {
			$p = new TreatingPatientProcessor($this);
			$result['result'] = $p->buildTestTicketInfoCashierHtml($patienId);
			

		} catch (InpatientCoreException $ex) {

			$result['error']['code'] = $ex->getErrorCode();
			$result['error']['mess'] = InPatientCoreErrorCode::getErrorMess($ex->getErrorCode());
			$this->logger->error('Load actionViewPatientTestAjax fail. Error detail: '. $ex->getMessage());
		} catch (EnumException $ex) {
            $result['error']['code'] = $ex->getErrorCode();
            $result['error']['mess'] = CoreErrorCode::getErrorMess($ex->getErrorCode());
            $this->logger->error('Load actionViewPatientTestAjax fail. Error detail: '. $ex->getMessage());
        }
		$this->logger->info('Finish actionViewPatientTestAjax');
		return $result['result'];

	}
	
    function actionViewPatientTestDetailAjax() {
        $result = array('error'=>array('code'=>0,'mess'=>''), 'result'=>'');
        $this->logger->info('Start actionViewPatientTestDetailAjax');
        $testDiagnosisTicketId = $_GET['testDiagnosisTicketId'];
        try {
            $p = new TreatingPatientProcessor($this);
            $result['result'] = $p->buildTestTicketDetailCashierHtml($testDiagnosisTicketId);
            

        } catch (InpatientCoreException $ex) {

            $result['error']['code'] = $ex->getErrorCode();
            $result['error']['mess'] = InPatientCoreErrorCode::getErrorMess($ex->getErrorCode());
            $this->logger->error('Load actionViewPatientTestDetailAjax fail. Error detail: '. $ex->getMessage());
        }  catch (EnumException $ex) {
            $result['error']['code'] = $ex->getErrorCode();
            $result['error']['mess'] = CoreErrorCode::getErrorMess($ex->getErrorCode());
            $this->logger->error('Load actionViewPatientTestDetailAjax fail. Error detail: '. $ex->getMessage());
        }
        $this->logger->info('Finish actionViewPatientTestDetailAjax');
        return json_encode($result);

    }
	
   

}
?>